package ch.be.coop.unterhaltLaden.presentation.framesPanels;

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.Point;

import javax.swing.JFrame;
import javax.swing.JPanel;

import ch.be.coop.unterhaltLaden.busines.Engine;
import ch.be.coop.unterhaltLaden.exceptions.presentationExceptions.Presentationexception;

public class Mainframe extends JFrame{

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	private Engine engine;
	private Dimension frameSize = new Dimension(600, 700);
	private Point displayPosition  = new Point(200, 200);
	private JPanel listpanel;
	
	public Mainframe(Engine engine) throws Presentationexception{
		
		this.setName("mainframe");
		
		if (engine != null) {
			this.engine = engine;
		}else{
		throw new Presentationexception("No Engine found");
		}
		
		this.setDefaultCloseOperation(EXIT_ON_CLOSE);
		this.setSize(this.frameSize);
		this.setLocation(this.displayPosition);
		
		this.setLayout(new BorderLayout());
		
		this.add(new TitlePanel(this.engine),BorderLayout.NORTH);
		
		this.add(new ButtonPanel(engine),BorderLayout.EAST);
		listpanel = new ListPanel(engine);
		this.add(listpanel,BorderLayout.CENTER);
		
		this.setVisible(true);
	}

	public JPanel getListpanel() {
		return listpanel;
	}
	

}
